package com.multiplepb.controller;

import com.microsoft.playwright.BrowserContext;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import com.multiplepb.config.StageRouter;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;

import java.net.URL;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.ResourceBundle;

/**
 */
@Slf4j
@Controller
public class PbMulPlatformController implements Initializable {
    private final StageRouter router;
    public PbMulPlatformController(StageRouter router) {
        this.router = router;
    }




    @Override
    public void initialize(URL url, ResourceBundle resourceBundle) {

    }


    @FXML
    public void pbVideo(ActionEvent actionEvent) {
        Playwright playwright = Playwright.create();
        BrowserType chromium = playwright.chromium();
        BrowserContext browserContext = chromium.launchPersistentContext(Path.of("G:\\cache"),
                new BrowserType.LaunchPersistentContextOptions()
                        .setHeadless(false)
                        .setArgs(Arrays.asList("--start-maximized"))
                        .setChannel("chrome")
                        .setViewportSize(null)
        );
        Page page = browserContext.newPage();
        page.navigate("https://www.baidu.com/");
        System.out.println("发布视频");
    }
}
